<?php
if (!defined("CONFIG_CLASS_PHS")) {
	define("CONFIG_CLASS_PHS",1);
	require_once('MyException.class.php');
	require_once('Constant888.class.php');
	$Constant888 = Constant888::instance();
	class Config888 {


		/**
		 * @desc Get the value of some variable in config file
		 * @param $left_string
		 * @return string the rightside of $leftstring in the config file
		 *
		 * Example in 'wap888.cfg':
		 * -------------------------
		 * ....
		 * MB_Today = c:\wamp\www\WAP888\Data\live_MB.xml
		 * ....
		 * -------------------------
		 * then: getValue("MB_Today") returns "c:\wamp\www\WAP888\Data\live_MB.xml"
		 */
		static public function getValue($left_string) {
			global $Constant888;
			$cfgFile = fopen($Constant888 -> value("CONFIG_FILE_NAME"),"r");
			while ($line = fgets($cfgFile)) {
				$paras = explode("=",$line);
				if ( trim($paras[0]) == $left_string ) {
					return trim($paras[1]);
				}
			}
			throw MyException();
		}

		static function getAllDatabaseInfo() {
			$dbStr = self::getValue("DatabaseInfo");
			$arr = explode(':',$dbStr);
			$retArr = array(
			'server' => $arr[0],
			'username' => $arr[1],
			'password' => $arr[2],
			'db_name' => $arr[3]		
			);
			return $retArr;
		}
		
			
			
	}


}
?>
